file=$1
dir=$2

cpath=$3

echo setting run...
run=$(echo $file|tr -s '/' '\n' | grep ".root" | awk -F\. '{print $1}')
echo setting done

cpath="$cpath/$run"

echo
echo file: $file
echo dir: $dir
echo run: $run
echo cpath: $cpath
echo

cd $dir
mkdir -p $run
cd $run

echo setting TMPDIR
export TMPDIR=/lustre/alice/xlu/mytmp

pwd

##############################################################################

cat > $run.sh <<EOF 

which aliroot

fin=$file
opt=11
tb0=-1
tb1=1000
cdb=$cpath

../newdraw \$fin \$opt \$tb0 \$tb1 \$cdb

EOF

chmod +x $run.sh 

./$run.sh  

#> see.log

#bsub -E $myBIN/preexec.sh -q alice-t3_2h -o oe$run $run.sh
#bsub -E $myBIN/preexec.sh -q proof -o oe$run $run.sh

cd $dir

